<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>生命周期</h2>
      <p>count: {{ count }}</p>
      <button @click="count++">btn</button>
    </div>

    <script src="./vue.js"></script>
    <script>
      Vue.createApp({
        data() {
          return {
            count: 10,
          };
        },
        beforeCreate() {
          console.log("beforeCreate", this.count);
          // fetch("http://www.pudge.wang:3080/api/overview")
          //   .then((response) => response.json())
          //   .then((res) => {
          //     console.log(res);
          //   });
        },
        created() {
          console.log("created", this.count);
        },
        beforeMount() {
          console.log("beforeMount", document.querySelector("h2"));
        },
        mounted() {
          console.log("mounted", document.querySelector("h2"));
          // window.addEventListener("resize", () => {})
        },
        updated() {
          console.log("updated");
          // this.count++;
        },
        beforeUnmount() {
          // 取消定时器
          // 取消js的事件监听
          // websocket长连接
          // 图表或者地图的实例
        },
      }).mount("#app");
    </script>
  </body>
</html>
